package work20241203_chap6oop;

/**
 * @author zdl
 * @date 2024/12/3
 */
class Department{
    private String dName;
    private Employee[] employee;

    public Department() {
    }

    public Department(String dName, Employee[] employee) {
        this.dName = dName;
        this.employee = employee;
    }

    public String getdName() {
        return dName;
    }

    public void setdName(String dName) {
        this.dName = dName;
    }

    public Employee[] getEmployee() {
        return employee;
    }

    public void setEmployee(Employee[] employee) {
        this.employee = employee;
    }
}
class Employee{
    private String eName;
    private char sex;
    private int age;

    public Employee() {
    }

    public Employee(String eName, char sex, int age) {
        this.eName = eName;
        this.sex = sex;
        this.age = age;
    }

//    @Override
//    public String toString() {
//        return "Employee{" +
//                "eName='" + eName + '\'' +
//                ", sex=" + sex +
//                ", age=" + age +
//                '}';
//    }

    public String geteName() {
        return eName;
    }

    public void seteName(String eName) {
        this.eName = eName;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
public class Demo2 {
    public static void main(String[] args) {
        Employee e = new Employee();
        e.seteName("小一");
        e.setAge(20);
        e.setSex('男');
        Employee e1 = new Employee();
        e1.seteName("小二");
        e1.setAge(22);
        e1.setSex('女');
        Employee e2 = new Employee();
        e2.seteName("小三");
        e2.setAge(23);
        e2.setSex('女');
        Employee e3 = new Employee();
        e3.seteName("小四");
        e3.setAge(24);
        e3.setSex('男');
        Employee e4 = new Employee();
        e4.seteName("小五");
        e4.setAge(26);
        e4.setSex('男');
        Employee[] employees = new Employee[5];
        employees[0] = e;
        employees[1] = e1;
        employees[2] = e2;
        employees[3] = e3;
        employees[4] = e4;
        Department department = new Department();
        department.setdName("技术部");
        department.setEmployee(employees);
        System.out.println(department.getdName());
        for (Employee employee:employees) {
            System.out.println(employee.geteName()+"\t"+employee.getSex()+"\t"+employee.getAge());
        }
//        for (int i = 0; i < employees.length; i++) {
//            System.out.println(employees[i].geteName()+"\t"+employees[i].getAge()+"\t"+employees[i].getSex());;
//        }
    }
}
